package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 统计表
 */
@Entity
@JsonApiResource(type = "statquery")
@Table(name = "tnb_statquery")
// @JsonIgnoreProperties(value={"hibernateLazyInitializer","handler"})
public class StatQuery extends BaseEntity {

	private Dicttype statType;// 类型

	private Integer durType;// 统计区间,1:年 2季 3月 4周 5日

	private Integer beginTime;// 开始日期

	private Integer endTime; // 结束日期
	/* 查询结果相关 */
	private Integer statResult;// 结果数据

	private Integer statDate;// 结果日期

	private Dicttype statItemType;// 口径
	
	private Integer createDateTime;
	
	private NursingLevel level;// 护理等级
	
	private Employee employee;
	
	private Integer passengers;
	
	private String passengersGrade;
	
	@Column(name = "passengers")
	public Integer getPassengers() {
		return passengers;
	}

	public void setPassengers(Integer passengers) {
		this.passengers = passengers;
	}

	@Column(name = "passengers_grade")
	public String getPassengersGrade() {
		return passengersGrade;
	}

	public void setPassengersGrade(String passengersGrade) {
		this.passengersGrade = passengersGrade;
	}

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "employee_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "level_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public NursingLevel getLevel() {
		return level;
	}

	public void setLevel(NursingLevel statItemType) {
		this.level = statItemType;
	}
	
	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}


	@Transient
	public Integer getDurType() {
		return durType;
	}

	public void setDurType(Integer durType) {
		this.durType = durType;
	}

	@Transient
	public Integer getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(Integer beginTime) {
		this.beginTime = beginTime;
	}

	@Transient
	public Integer getEndTime() {
		return endTime;
	}

	public void setEndTime(Integer endTime) {
		this.endTime = endTime;
	}

	@Column(name = "stat_result")
	public Integer getStatResult() {
		return statResult;
	}

	public void setStatResult(Integer statResult) {
		this.statResult = statResult;
	}

	@Column(name = "stat_date")
	public Integer getStatDate() {
		return statDate;
	}

	public void setStatDate(Integer statDate) {
		this.statDate = statDate;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "stat_type", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public Dicttype getStatType() {
		return statType;
	}

	public void setStatType(Dicttype statType) {
		this.statType = statType;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "stat_item", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public Dicttype getStatItemType() {
		return statItemType;
	}

	public void setStatItemType(Dicttype statItemType) {
		this.statItemType = statItemType;
	}

}